package com.ktjy.service;

import com.ktjy.entity.SysUser;
import com.ktjy.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {
    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public List<SysUser> getSysUserList(SysUser sysUser) {
        return sysUserMapper.getSysUserList(sysUser);
    }

    @Override
    public int saveBatch(List<SysUser> sysUserList) {
        int rows=0;
        for (int i = 0; i < sysUserList.size(); i++) {
            SysUser sysUser = sysUserList.get(i);
            if (i==1){
                throw new RuntimeException("数据库异常");
            }
            rows+= sysUserMapper.insert(sysUser);
        }
        return rows;
    }

    @Override
    public int delete(int id) {
        return sysUserMapper.delete(id);
    }

    @Override
    public int update(SysUser sysUser) {
        return sysUserMapper.update(sysUser);
    }
}
